  var easymana_tableId = "t_table"; //table grid ID
  var easymana_formName = "";
  var easymana_form = null;
  var cur_row = -1;
  var cur_row_tr = null;

  function setTableId(tid){
  	easymana_tableId = tid;
  }
  function setFormName(fn){
  	easymana_formName = fn;
  	easymana_form = eval("document." + easymana_formName);
  }
  //------------表单操作-----------------//
  //表单操作事件
  function operateForm(operateType){
	  if(operateType == "delete"){
		    if(cur_row == -1){
		    	alert("请选中要删除的行。");
		    	return;
		    }
		    var dt = document.getElementById(easymana_tableId).children[0];
		    var idValue = eval("document.all." + easymana_formName + ".id.value");
		    if(idValue == ""){
		    	var cur_tr = dt.children[cur_row];
		    	dt.removeChild(cur_tr);
		    	cur_row = cur_row - 1;
		    	cur_tr = dt.children[cur_row];
		    	copy(cur_tr,true);
		    	return;
		    }
	    }
    if(operateType == "delete"){
    	if(!confirm("请确认您要删除数据!")) return;
    }
	if(operateType == 'add' || operateType == 'update'){
		if(!checkForm(easymana_form)){
			return;
		}
	}
	//alert(eval("document." + easymana_formName + ".id.value"));
  	eval("document." + easymana_formName + ".action = document." + easymana_formName + ".action + " + "'?action=" + operateType + "';");
  	eval("document." + easymana_formName + ".submit()");
  }
  
  //改变行
  function changeBack(row){
	cur_row = row.rowIndex;
	if(cur_row_tr != null){
		cur_row_tr.style.backgroundColor="#F9F8E8";
	}
	row.style.backgroundColor="#EEE999";
	cur_row_tr = row
 }
 
 //增加一条记录
 function addRecord(){
 	var dt = document.getElementById(easymana_tableId);
 	var dtbody = dt.children[0];
 	var newrow = dt.rows(1).cloneNode(true);
 	for (var i=0;i<newrow.children.length;i++) {
 		if(i == 0){
 			newrow.children[i].innerText = "";
 		}else{
			newrow.children[i].innerText = "default";
		}
	}
	dtbody.appendChild(newrow);
 	newrow.style.backgroundColor="#DCDCDC";
 }



function mOvr(roww) {
	roww.style.cursor = "hand";
	if(roww != cur_row_tr){
		roww.style.backgroundColor = "#FFF8C5";
	}
}
function mOut(roww) {
	roww.style.cursor = "default";
	roww.style.backgroundColor = "#F9F8E8";
	if(cur_row_tr != null){
		cur_row_tr.style.backgroundColor = "#EEE999";
	}
}
function dispTd(id){
	var tdiv = document.getElementById(id);
	var disp = document.getElementById("display");
	disp.style.left = event.clientX;
	disp.style.top = event.clientY;
	disp.innerHTML = tdiv.innerHTML;
	disp.style.display="block";
}

function hideTd(id){
	var disp = document.getElementById("display");
	disp.innerHTML = "";
	disp.style.display="none";
}